package dto

import (
	"tuowei.com/app/api/models"
	common "tuowei.com/common/models"
)

type SysAddressGetPageReq struct {
	StudentId int `json:"student_id" search:"type:exact;column:student_id;table:sys_address" comment:"学员id"` // 学员id
}

func (m *SysAddressGetPageReq) GetNeedSearch() interface{} {
	return *m
}

type SysAddressInsertReq struct {
	StudentId       int    `json:"student_id" comment:"学员id"`                 // 学员id
	GoodsName       string `json:"goods_name" comment:"收获人姓名"`                // 收货人姓名
	GoodsTel        string `json:"goods_tel" comment:"收获人电话"`                 // 收货人电话
	Region          string `json:"region" comment:"地区"`                       // 地区
	DetailedAddress string `json:"detailed_address" comment:"详细地址"`           // 详细地址
	DefaultAddress  int    `json:"default_address" comment:"是否默认,1是默认，2不是默认"` // 是否默认
	common.ControlBy
}

func (s *SysAddressInsertReq) Generate(model *models.SysAddress) {
	//model.CourseId = s.CourseId
	model.StudentId = s.StudentId
	model.GoodsName = s.GoodsName
	model.GoodsTel = s.GoodsTel
	model.Region = s.Region
	model.DetailedAddress = s.DetailedAddress
	if s.DefaultAddress == 1 {
		model.DefaultAddress = s.DefaultAddress
	} else {
		model.DefaultAddress = 2
	}

}

func (s *SysAddressInsertReq) GetId() interface{} {
	return s.StudentId
}

type SysAddressUpdateReq struct {
	Id              int    `json:"id" comment:"id"`                           // id
	GoodsName       string `json:"goods_name" comment:"收获人姓名"`                // 收货人姓名
	GoodsTel        string `json:"goods_tel" comment:"收获人电话"`                 // 收货人电话
	Region          string `json:"region" comment:"地区"`                       // 地区
	DetailedAddress string `json:"detailed_address" comment:"详细地址"`           // 详细地址
	DefaultAddress  int    `json:"default_address" comment:"是否默认,1是默认，2不是默认"` // 是否默认
	common.ControlBy
}

func (s *SysAddressUpdateReq) Generate(model *models.SysAddress) {
	if s.Id != 0 {
		model.Id = s.Id
	}
	if s.GoodsName != "" {
		model.GoodsName = s.GoodsName
	}
	if s.GoodsTel != "" {
		model.GoodsTel = s.GoodsTel
	}
	if s.Region != "" {
		model.Region = s.Region
	}
	if s.DetailedAddress != "" {
		model.DetailedAddress = s.DetailedAddress
	}
	if s.DefaultAddress == 1 || s.DefaultAddress == 2 {
		model.DefaultAddress = s.DefaultAddress
	}
	model.CreateBy = s.CreateBy
}

func (s *SysAddressUpdateReq) GetId() interface{} {
	return s.Id
}

type SysAddressDeleteReq struct {
	Id int `json:"id"`
}

func (s *SysAddressDeleteReq) GetId() interface{} {
	return s.Id
}
